String .trim() method in java

59

String .trim() method in java -

// Java program to demonstrate working
// of java string trim() method
 
class Gfg {
 
    // driver code
    public static void main(String args[])
    {
 
        // trims the trailing and leading spaces
        String s = " geeks for geeks has all java functions to read  ";
        System.out.println(s.trim());
 
        // trims the leading spaces
        s = " Chetna loves reading books";
        System.out.println(s.trim());
    }
}

Comments

Submit
0 Comments